/*
题目链接 : https://leetcode.cn/problems/prime-in-diagonal/?envType=daily-question&envId=2025-03-18
*/

//题解代码 : 
class Solution {
public:
    bool isprime(int x){
        if(x <= 1) return false;
        for(int i=2;i*i<=x;++i){
            if(x%i == 0) return false;
        }
        return true;
    }
    int diagonalPrime(vector<vector<int>>& a) {
        int n = a.size();
        int m = a[0].size();
        int ans = 0;
        for(int i=0;i<n;++i){
            if(isprime(a[i][i])) ans = max(ans,a[i][i]);
            if(isprime(a[i][n-i-1])) ans = max(ans,a[i][n-i-1]);
        }
        return ans;
    }
};
